import axios from 'axios'

import 'nprogress/nprogress.css' 
import Npregress from 'nprogress'

const mockAjax = axios.create({
    baseURL:'/mock',
    timeout:1000,
})

mockAjax.interceptors.request.use(config => {
    Npregress.start()

    return config
})

mockAjax.interceptors.response.use(response => {
    Npregress.done()
    return response.data
    
},error => {
    Npregress.done()
    return Promise.reject(new Error(error.message))
})

export default mockAjax